<template>
    <div>
      <div class="banner__wrap">
        <div @click="showGalaryImg" >
          <img src="http://img1.qunarzz.com/sight/p0/201404/23/04b92c99462687fa1ba45c1b5ba4ad77.jpg_600x330_bf9c4904.jpg" alt="">
          <div class="banner__info">
            <p class="info__name">大连圣亚海洋世界(AAAA景区大连圣亚海洋世界(AAAA景区大连圣亚海洋世界(AAAA景区)</p>
            <p class="info__num"><i class="iconfont icon-tupian"></i>39</p>
          </div>
        </div>
        <router-link tag="div" to="/" class="banner__backBtn"><i class="iconfont icon-fanhui"></i></router-link>
        <commonGallary :imgs="imgs" v-show="showGalary" @hideGallary="hide"></commonGallary>
      </div>
      <div class="banner__header" v-show="isScroll" :style="hideOpacity">
        <div class="header">
          <router-link to="/">
            <div class="header__back"><i class="iconfont icon-fanhui"></i></div>
          </router-link>
          <div class="header__title">景点详情</div>
        </div>
      </div>
      <div class="content">
      </div>
    </div>
</template>

<script>
import commonGallary from 'common/gallary/Gallary'
export default {
  name: 'detailBanner',
  data () {
    return {
      showGalary: false,
      isScroll: false,
      hideOpacity: { opacity: 0 },
      imgs: ['http://img1.qunarzz.com/sight/p0/201404/23/04b92c99462687fa1ba45c1b5ba4ad77.jpg_800x800_70debc93.jpg',
        'http://img1.qunarzz.com/sight/p0/1709/76/7691528bc7d7ad3ca3.img.png_800x800_9ef05ee7.png']
    }
  },
  components: {
    commonGallary
  },
  methods: {
    showGalaryImg () {
      this.showGalary = true
    },
    hide () {
      this.showGalary = false
    },
    toggleHeader () {
      const top = document.documentElement.scrollTop
      if (top > 86) {
        let opacity = top / 160
        opacity = opacity > 1 ? 1 : opacity
        this.hideOpacity = { opacity }
        this.isScroll = true
      } else {
        this.isScroll = false
      }
    }
  },
  activated () {
    window.addEventListener('scroll', this.toggleHeader)
  },
  deactived () {
    window.removeEventListener('scroll', this.toggleHeader)
  }
}
</script>

<style lang='stylus' scoped>
  @import "~@/assets/css/varible.styl"
  .banner__wrap {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 0;
    padding-bottom: 55%;
    img {
      width: 100%;
      height: auto;
    }
    .banner__info {
      display: flex;
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      padding: 20px;
      line-height 32px;
      color: #fff;
      background-image: linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, .8))
      p {
        height: 32px;
      }
      p.info__name {
        txt-elipsis ()
        padding-right: 20px;
        font-size: 24px;
      }
      p.info__num {
        height: 32px;
        padding: 0 20px;
        background: rgba(0, 0, 0, .8);
        border-radius: 20px;
        font-size: 16px;
        .iconfont {
          padding-right: 6px;
        }
      }
    }
    .banner__backBtn {
      position: fixed;
      top: 20px;
      left: 20px;
      height: 60px;
      width: 60px;
      background: rgba(0, 0, 0, .6);
      border-radius: 50%;
      color: #fff;
      line-height: 60px;
      text-align: center;
      .iconfont {
        font-size: 32px;/*px*/
      }
    }
  }
  .header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    line-height: 86px;
    color: #fff;
    z-index: 999999;
    .header__back {
      position: absolute
      left: 20px
      color: #eee
    }
    .iconfont {
      font-size: 45px; /*px*/
      cursor: pointer;
      color: #eee
    }
  }
  .header__title
    font-size: 32px;/*px*/
    background: #00bcd4
    text-align: center
  .content
    height: 2500px;
    background: #666;
</style>
